home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
snip9_91.arc
/
ATR2ANSI.C1
< prev
next >
Wrap
Text File
|
1991-09-17
|
3KB
|
69 lines
/************************************************************************/
/* Video attribute to ANSI command processor */
/* */
/* This is a short program demonstrating a technique for reading */
/* the current screen video attribute and using it to build */
/* command strings for ANSI.SYS-compatible color. */
/* */
/* Public domain demo by Bob Stout */
/* */
/************************************************************************/
#include <stdio.h>
#include <dos.h>
#include <mflconio.h> /* Part of MFLZT shareware library */
#define PAGE(title)
PAGE(main) /* Used by MicroFirm PR for listing */
/* First define the black and white defaults */
int vid_nrm = 0x7, /* Normal video mode (wht on blk) */
vid_rev = 0x70, /* Reverse video mode (blk on wht) */
vid_grf = 0x7, /* Line graphics (same as normal) */
vid_grv = 0x70; /* Reverse graphics (same as reverse) */
int vid_mode;
char *my_color, *your_color;
main()
{
int oldvatr;
char *p;
union REGS regs;
char *make_ansi(int);
regs.h.ah = 0xf; /* Get display page in bh */
int86(0x10,®s,®s);
vid_mode = regs.h.al; /* Save video mode */
regs.h.ah = 0x8; /* get color/attribute */
int86(0x10,®s,®s);
oldvatr = regs.h.ah;
your_color = make_ansi(oldvatr);
if (vid_mode != MONO)
{
if (vid_mode != CLR80)
vmode(CLR80);
printf("\nWe need to print something in the standard"
" screen color\n\n");
/* Change the foreground */
my_color = make_ansi(oldvatr ^ 0x4);
printf("%sFirst we'll change the foreground...%s\n",
my_color, your_color);
/* Change the background */
my_color = make_ansi(oldvatr ^ 0x44);
printf("%s...then we'll change the background%s\n\n",
my_color, your_color);
/* Return to the way it was */
printf("Now we'll show things are back the way they were\n");
}
else printf("\aSorry, B&W doesn't cut it\n");
}